﻿var windowLanguage = "cn.xml";

var flashObjId = "videoFlash";
var DEF_WINDOW_NUM = "WindowNum";
var DEF_Max_Picture = 'MaxPicture';
var windowCurNum = 9;		//当前显示数目
var windowMaxNum = 36;	//最多的数目 

var DEF_VIEW_SIZE = "ViewSize";
var DEF_Video_Set = 'VideoSet';
var DEF_Speak = 'Speak';

var viewSize = "full";	//full 4:3  16:9

var DEF_BUFFER_TIME = "BufferTime";	//缓冲时长
var bufferTime = 0.8;
var bufferTimeMax = 1.5;
var fastBufferTime = 1;		//实时要小于1
var fastBufferTimeMax = 2;
var smoothBufferTime = 6;		//流畅要大于1
var smoothBufferTimeMax = 0;

var rootParent = {};
var isInitFinished = false;
var lang = new langChinese();

var loginServer = null;
var isLoadLoginServer = false;

var ttxPlayer = null;


var osdDataMap = {};

/**
 * @method 初始化flash播放器
 * @param serverIp 视频服务器IP地址
 * @param rtmpPort 视频服务器RTMP端口
 * @param httpUrl web服务器根路径，如http://221.192.133.25:18080/
 * @param maxVideoPreviewTime 视频最长浏览时间(超过后，强制断开)
 * @param maxAudioListeningTime 音频监听的最长监听时间
 * @param isPlayback  默认是false, 如果播放器是是用于回放，则为true, 用于判断当播放器停止的时候，是下发停止实时视频指令还是停止回放指令
 * @return {返回值类型} 返回值说明
 */
function initVideoPlayer(serverIp, rtmpPort,httpUrl, maxVideoPreviewTime,maxAudioListeningTime,isPlayback, httpUploadPictureUrl, httpStartVideoRecordUrl, httpEndVideoRecordUrl) {
    loginServer = {};
    loginServer.ip = serverIp;
    loginServer.port = "18080";
    loginServer.httpUrl = httpUrl;
    loginServer.rtmpPort = rtmpPort;
    loginServer.httpUploadPictureUrl = httpUploadPictureUrl;
    loginServer.httpStartVideoRecordUrl = httpStartVideoRecordUrl;
    loginServer.httpEndVideoRecordUrl = httpEndVideoRecordUrl;

    isLoadLoginServer = true;
	loadLang();
	setPanelWidth();
	loadVideo(maxVideoPreviewTime,maxAudioListeningTime,isPlayback);
	/*
    $(document).bind("click mouseup",function(e){
    	if (typeof parent.ttxPlayerDocumentMouseClick == "function") {
    		parent.ttxPlayerDocumentMouseClick();
    	}
    }).mousemove(function(e){
    	if (typeof parent.ttxPlayerDocumentMouseMove == "function") {
    		parent.ttxPlayerDocumentMouseMove(e);
    	}
    });*/
    
    //是否隐藏工具栏
    var hideTool = getUrlParameter("hideTool");
	if(hideTool == null || !hideTool) {
		$('.tv_box').show();
	}
    var showTitle = getUrlParameter("showTitle");
    if(showTitle != null && showTitle) {
    	$('.tv_play').show();
    	$('.tv_play .tv_play_span').show();
    }
    var changeSize = getUrlParameter("changeSize");
    if(changeSize != null && changeSize) {
    	$('.tv_play').show();
    	$('.tv_play .btn_tv_icon').show();
    }
    
    $("#box_top").hide();
    $("#box_bottom").hide();
    $(".icon_num1").click(function() {
    	doSwitchWindow(1);
    });
    $(".icon_num2").click(function() {
    	doSwitchWindow(4);
    });
    $(".icon_num3").click(function() {
    	doSwitchWindow(6);
    });
    $(".icon_num4").click(function() {
    	doSwitchWindow(8);
    });
    $(".icon_num5").click(function() {
    	doSwitchWindow(9);
    });
    $(".icon_num6").click(function() {
    	doSwitchWindow(16);
    });
    var picture = $.cookie(DEF_Max_Picture);
    if(picture && picture == 1){
    	windowMaxNum = 25;
	    $(".icon_num7").click(function() {
	    	doSwitchWindow(25);
	    });
	    $(".icon_num8").parent().hide();
    }else if(picture && picture == 2){
    	windowMaxNum = 36;
    	$(".icon_num7").click(function() {
	    	doSwitchWindow(25);
	    });
	    $(".icon_num8").click(function() {
	    	doSwitchWindow(36);
	    });
    }else {
    	windowMaxNum = 16;
    	$(".icon_num7").parent().hide();
    	$(".icon_num8").parent().hide();
    }
    $(".icon_num9").click(function() {
        InfoWindow.editUserPreference();
    });
	//视频显示比例
	$("#box_viewSize").hover(
		function(){
			$(this).find("ul").show();
			},
		function(){
			$(this).find("ul").hide();
	});
	$("#view4X3").click(function() {
		doViewSize("4:3");
	});
	$("#view16X9").click(function() {
		doViewSize("16:9");
	});
	$("#viewFull").click(function() {
		doViewSize("full");
	});
	//视频显示比例
	$("#box_viewMode").hover(
		function(){
			$(this).find("ul").show();
			},
		function(){
			$(this).find("ul").hide();
	});
	$("#bufferShort").click(function() {
		doBufferTime(fastBufferTime);
	});
	$("#bufferLong").click(function() {
		doBufferTime(smoothBufferTime);
	});
	$("#box_capture").hide();
	//$("#box_voice").hide();

	$(".icon_play_all").click(function() {
		doPlayAll();
	});
	$("#stopAll").click(function() {
		doCloseAll();
	});
	$("#clearAll").click(function() {
		doClearAll();
	});
	//停止视频
	$("#box_stop").hover(
		function(){
			$(this).find("ul").show();
			},
		function(){
			$(this).find("ul").hide();
	});
	$(".btn_tv_icon").click(function(){
		if( $(this).hasClass("btn_tv_min") ){
			$(this).removeClass("btn_tv_min").addClass("btn_tv_max");
			if(typeof parent.doClickHideMap == 'function') {
				parent.doClickHideMap(true);
			}
		}else{
			$(this).removeClass("btn_tv_max").addClass("btn_tv_min");
			if(typeof parent.doClickHideMap == 'function') {
				parent.doClickHideMap(false);
			}
		}
	});
}

function isWindowPreviewing()
{
	return ttxPlayer.isWindowPreviewing();
}

/**
 * 根据实时gps数据，不断刷新屏幕的osd叠加字幕
 * @param osdConfig
 */
function refreshOsdOnTime(osdConfig)
{
    var simNoList = ttxPlayer.getCurrentChnWindowDevIdList();
    if(simNoList == null || simNoList.length == 0)
	{
		//ttxPlayer.clearOsdText();
		return;
	}
    var osdTypeArray = osdConfig.osdType.split(",");
    var url = globalConfig.webPath+"/realData/refreshOsdData.action";
    var me = this;
    var params = {"simNoList":simNoList};
    $.ajax({
        type: "POST",
        traditional: true,
        url: url,
        data:params,
        error:function(){

        },
        success: function(data){
            var result =  data;
            if(result.success)
            {
				var data = result.data;
				$.each(data, function(i,gpsRealData)
				{
                    var osdStr = "";
                    var sep = "";
                    $.each(osdTypeArray, function(k,v)
                    {
                        osdStr += sep + gpsRealData[v];
                        if(v=="velocity")
                        	osdStr += "km/h";
                        sep = ",";
                    })

					osdDataMap["0"+gpsRealData.simNo] = osdStr;
				})
                ttxPlayer.displayOsdText(osdConfig,osdDataMap);
            }else
            {
                console.log("osd数据获取错误;"+result.message);
            }
        }
    });

}

/*
author:shinion
date:2019-01-08
获取视频请求信息并设置
*/
function  getVideoDataUsage() {
    var url = globalConfig.webPath+"/videoRequest/getMyVideoRequest.action";
    var me = this;
    var params = {};
    $.getJSON(url, params, function(result)
    {
        if(result.success)
        {
            var videoRequestList = result.data;
            $.each(videoRequestList,function(i,v)
            {

                var flow = v.flow / 1024;
                flow = flow.toFixed(2);

                var title = v.plateNo + " 通道" + v.channelId;
                if(flow > 0)
                  title += " " + flow + "M";
                var simNo = v.simNo.length > 11 ? v.simNo : ("0" + v.simNo);
                me.setVideoInfo(simNo, v.channelId, v.streamType,
                    title);

            })

        }
    });
}

/*
author:shinion
date:2019-01-08
设置最大画面

*/
function setMaxPicture(){
	var picture = $.cookie(DEF_Max_Picture);
    if(picture == 0){
    	windowMaxNum = 16;
    	$(".icon_num7").parent().hide();
    	$(".icon_num8").parent().hide();
    }else if(picture == 1){
    	windowMaxNum = 25;
    	$(".icon_num7").parent().show();
	    $(".icon_num7").click(function() {
	    	doSwitchWindow(25);
	    });
	    $(".icon_num8").parent().hide();
    }else if(picture == 2){
    	windowMaxNum = 36;
    	$(".icon_num7").parent().show();
    	$(".icon_num8").parent().show();
    	$(".icon_num7").click(function() {
	    	doSwitchWindow(25);
	    });
	    $(".icon_num8").click(function() {
	    	doSwitchWindow(36);
	    });
    }
}

/*
author:shinion
date:2019-01-08
设置语言

*/
function loadLang() {
	//setTooltip( ".icon_num1", lang.video_1view);
	//setTooltip( ".icon_num2", lang.video_4view);
	//setTooltip( ".icon_num3", lang.video_6view);
	//setTooltip( ".icon_num4", lang.video_8view);
	//setTooltip( ".icon_num5", lang.video_9view);
	//setTooltip( ".icon_num6", lang.video_16view);
	//setTooltip( ".icon_num7", lang.video_25view);
	//setTooltip( ".icon_num8", lang.video_36view);
	$('.tv_play_span').text(lang.video_play);
	$("#view4X3").html('<i class="icon icon_gou"></i>' + lang.video_size_4X3 + '</a>');
	$("#view16X9").html('<i class="icon icon_gou"></i>' + lang.video_size_16X9 + '</a>');
	$("#viewFull").html('<i class="icon icon_gou"></i>' + lang.video_size_full + '</a>');
	$("#bufferShort").html('<i class="icon icon_gou"></i>' + lang.video_mode_good + '</a>');
	$("#bufferLong").html('<i class="icon icon_gou"></i>' + lang.video_mode_normal + '</a>');
	setTooltip( ".icon_play_all", lang.video_play_all);
	setTooltip( ".icon_num9", lang.param_settings);
	$("#stopAll").html('<i class="icon icon_gou"></i>' + lang.video_stop_all + '</a>');
	$("#clearAll").html('<i class="icon icon_gou"></i>' + lang.video_clear_all + '</a>');
	//setTooltip( ".icon_close_show", lang.video_stop_all);
}

function setTooltip(id, tltle) {
	$( id ).attr("title", tltle);
	$( id ).tooltip();
}

function getServer() {
    loginServer = {};
    loginServer.ip = "127.0.0.1";
    loginServer.port = "18080";
    isLoadLoginServer = true;

	/**
	$.myajax.jsonGet('StandardLoginAction_getLoginServer.action', function(json,action,success){
		if(success) {
			var server = json.loginServer;
			var lstSvrIp = [];
			lstSvrIp.push(server[0].clientIp);
			lstSvrIp.push(server[0].lanip);
			lstSvrIp.push(server[0].clientIp2);
			loginServer = {};
			loginServer.ip = getComServerIp(lstSvrIp);
			loginServer.port = server[0].clientPort;
			isLoadLoginServer = true;
		} 
	}, null);*/
}


function setRefinterval() {
	if (typeof parent.setRefinterval == "function") {
		parent.setRefinterval();
	}
}

function setVideoCloseTime(closeVideoTime, closeSpeakTime)
{
    ttxPlayer.setAutoCloseVideoTime(closeVideoTime * 60 * 1000);
    ttxPlayer.closeVideoWindowTimer();

    ttxPlayer.setAutoCloseSpeakTime(closeSpeakTime * 60 * 1000);
    ttxPlayer.closeTalkListenWidowTimer();
}

function setCloseTime(){
	//自动关闭视频时间
	var closevideo = $.cookie(DEF_Video_Set);
	if(closevideo != null){
		closevideo = closevideo * 60 * 1000;
	}else{
		closevideo = 5 * 60 * 1000;
	}
	
	ttxPlayer.setAutoCloseVideoTime(closevideo);
	ttxPlayer.closeVideoWindowTimer();
	
	//自动关闭对讲和监听时间
	var closeSpeak = $.cookie(DEF_Speak);
	if(closeSpeak != null){
		closeSpeak = closeSpeak * 60 * 1000;
	}else{
		closeSpeak = 5 * 60 * 1000;
	}
	
	ttxPlayer.setAutoCloseSpeakTime(closeSpeak);
	ttxPlayer.closeTalkListenWidowTimer();
}

function setAlarmRefinterval(){
	if (typeof parent.setAlarmRefinterval == "function") {
		parent.setAlarmRefinterval();
	}
}


function setPanelWidth() {
	if (isInitFinished) {
		//var _width = document.documentElement.clientWidth;
		//var _height = document.documentElement.clientHeight;
	//	var _width = $(window).width();
	//	var _height = $(window).height() - 39;
		//$("#"+flashObjId).width(_width);
		//$("#"+flashObjId).height(_height - 39);
	} 
}


function isLoadVideoSuc() {
	return isInitFinished;
}

/**
 * 判断clientIp与url是否相同，取相同的clientIp  公用方法
 */
function getLoginServer() {
	if(isLoadLoginServer) {
		serverIp = loginServer.ip;
		serverPort = loginServer.port;
		var rtmpPort = loginServer.rtmpPort;
		//swfobject.getObjectById(flashObjId).setServerInfo(serverIp,serverPort,rtmpPort,loginServer.httpUrl);
        swfobject.getObjectById(flashObjId).setVideoServerInfo(serverIp, serverPort, rtmpPort, loginServer.httpUrl,
			loginServer.httpUploadPictureUrl, loginServer.httpStartVideoRecordUrl, loginServer.httpEndVideoRecordUrl);
		isInitFinished = true;
		setViewSize();
		setBufferTime();
		setPanelWidth();
	}else {
		setTimeout(getLoginServer,50);
	}
}

function setSoundVolume(value)
{
    swfobject.getObjectById(flashObjId).setSoundVolume(value);
}

function loadVideo(maxVideoPreviewTime,maxAudioListeningTime,isPlayback) {
	//窗口数目
	var curNum = $.cookie(DEF_WINDOW_NUM); 
	if (curNum == null) {
		curNum = 9;
	} else {
		windowCurNum = parseInt(curNum, 10);
	}
	var winNum = getUrlParameter("windowCurNum");
	if(winNum != null && winNum != '') {
		windowCurNum = Number(winNum);
	}
	//视频播放大小
	var size = $.cookie(DEF_VIEW_SIZE); 
	if (size != null) {
		viewSize = size;
	}
	//视频缓冲时间
	var buffTime = $.cookie(DEF_BUFFER_TIME); 
	if (buffTime != null) {
		bufferTime = parseInt(buffTime, 10);
	}
	//初始化视频
	ttxPlayer = new TtxPlayer();
    ttxPlayer.playbacking = isPlayback;
	//自动关闭视频时间
	var closevideo = maxVideoPreviewTime;//$.cookie(DEF_Video_Set);
	if(closevideo != null){
		closevideo = closevideo * 60 * 1000;
	}else{
		closevideo = 5 * 60 * 1000;
	}
	//自动关闭对讲和监听时间
	var closeSpeak = maxAudioListeningTime;//$.cookie(DEF_Speak);
	if(closeSpeak != null){
		closeSpeak = closeSpeak * 60 * 1000;
	}else{
		closeSpeak = 5 * 60 * 1000;
	}
	
	ttxPlayer.setAutoCloseVideoTime(closevideo);
	ttxPlayer.setAutoCloseSpeakTime(closeSpeak);
	ttxPlayer.initialize();
	
	//初始化flash
	//if(rootParent.langIsChinese()) {
		windowLanguage = './player/cn.xml'; 
	//} else {
		//windowLanguage = './player/en.xml';
	//}
    var params = {  
        allowFullscreen: "true",   
        allowScriptAccess: "always",   
        bgcolor: "#FFFFFF",
        wmode: "transparent"
    };
    //var width = $(window).width();
    //var height = $(window).height() - 39;

	var width = $("#"+flashObjId).width();
    var height = $("#"+flashObjId).height();

	swfobject.embedSWF("/video/player/player.swf", flashObjId, width, height, "11.0.0", null, null, params, null);
	setTimeout(initFlash, 50);
/*	$(".icon_num8").hide();
	//并发连接数目限制
	if ($.ua().isWebkit) {
		$(".icon_num4").hide();
		$(".icon_num5").hide();
		$(".icon_num6").hide();
		$(".icon_num7").hide();
	} */
}
var tryInitFlashTimes = 0;
function initFlash() {
	if (swfobject.getObjectById(flashObjId) == null ||
		typeof swfobject.getObjectById(flashObjId).setWindowNum == "undefined" ) {
        tryInitFlashTimes++;
        if(tryInitFlashTimes == 20)
		{
			//$.messager.alert("提示","Flash插件没有启用，请检查浏览器是否启用了flash");
			//return;
		}
		setTimeout(initFlash, 50);

	} else {
        tryInitFlashTimes = 0;
		//swfobject.getObjectById(flashObjId).setLanguage(windowLanguage);
		//先将全部窗口创建好
		swfobject.getObjectById(flashObjId).setWindowNum(windowMaxNum);
		//再配置当前的窗口数目
		swfobject.getObjectById(flashObjId).setWindowNum(windowCurNum);
		
		getLoginServer();
	}
}



//function onToolbarClick(index, btnIndex){
//	if (index != null && index != "") {
//		index = parseInt(index, 10);
//	}
//	ttxPlayer.onToolbarClick(index, btnIndex);
//}


/*
 * 取得焦点窗口
 */
function getCurFocusWindow(){
	if (!isInitFinished) {
		return null;
	}
	return ttxPlayer.getCurFocusWindow();
}

/**
 * @method 设置窗口画面是1,4,9,16,32
 * @param num
 */
function doSwitchWindow(num, saveCookie) {
	windowCurNum = num;
	//保存
	if(saveCookie != false)
	   $.cookie(DEF_WINDOW_NUM, this.windowCurNum, { expires: 365 });
	//切换窗口
	if (!isInitFinished) {
		return;
	}
	swfobject.getObjectById(flashObjId).setWindowNum(num);
	ttxPlayer.oneMaxMode = false;
}

function doViewSize(size) {
	//保存
	viewSize = size;
	$.cookie(DEF_VIEW_SIZE, viewSize, { expires: 365 }); 
	//更新
	setViewSize();
}

function setViewSize() {
	if (viewSize == "4:3") {
		$("#view4X3 i").addClass("icon_select");	
		$("#view16X9 i").removeClass("icon_select");
		$("#viewFull i").removeClass("icon_select");
	} else if (viewSize == "16:9") {
		$("#view4X3 i").removeClass("icon_select");
		$("#view16X9 i").addClass("icon_select");
		$("#viewFull i").removeClass("icon_select");
	} else {
		$("#view4X3 i").removeClass("icon_select");
		$("#view16X9 i").removeClass("icon_select");
		$("#viewFull i").addClass("icon_select");
	}
	if (!isInitFinished) {
		return ;
	}
	for (var i = 0; i < windowMaxNum; ++ i) {
		swfobject.getObjectById(flashObjId).setVideoFrame(i, viewSize);
	}
}

function doBufferTime(time) {
	//保存
	bufferTime = time;
	$.cookie(DEF_BUFFER_TIME, bufferTime, { expires: 365 }); 
	//更新
	setBufferTime();
}

function setBufferTime() {
	if (bufferTime <= 1.5) {
		bufferTimeMax = fastBufferTimeMax;
		$("#bufferShort i").addClass("icon_select");	
		$("#bufferLong i").removeClass("icon_select");
	} else {
		bufferTimeMax = smoothBufferTimeMax;
		$("#bufferShort i").removeClass("icon_select");
		$("#bufferLong i").addClass("icon_select");
	} 
	if (!isInitFinished) {
		return ;
	}
	for (var i = 0; i < windowMaxNum; ++ i) {
		swfobject.getObjectById(flashObjId).setBufferTime(i, bufferTime);
		if(!rootParent.myPageStyle || rootParent.myPageStyle.getStyle() != 'hb') {
			swfobject.getObjectById(flashObjId).setBufferTimeMax(i, bufferTimeMax);
		}
	}
}


function setVideoColor(brightness,color,contrast, saturation)
{
    swfobject.getObjectById(flashObjId).setVideoColor(brightness,color,contrast, saturation);
}

/**
 * 预览视频
 * @param devIdno 设置的sim卡号,前面需要补零，补足12位，如013200000002
 * @param arrChn	通道列表,数组形式，如[1,2,4]
 * @param stream	码流类型  0 主码流 1子码流
 * @param arrTitle	通道的文字描述，数组形式，如["苏A23512 通道1", "苏A23512 通道2","苏A23512 通道4"]
 * @param viewCloseTime	自动关闭时间
 * @param armType 报警信息默认为空
 * @param isVideo 是否是视频窗口
 */
function startVideo(devIdno, arrChn, stream, arrTitle, viewCloseTime, armType,isVedio) {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.startVideo(devIdno, arrChn, stream, arrTitle, viewCloseTime, armType,isVedio);
}
/**
 * 设置视频窗口的消息
 */
function setVideoInfo(devIdno,channel,stream,message)
{
    var ttxWindow = ttxPlayer.getCurrentChnWindow(devIdno,channel,stream);
	if(ttxWindow != null)
	{
		swfobject.getObjectById(flashObjId).setVideoInfo(ttxWindow.index, message);
	}
}

/**
 * 设置视频窗口的消息
 */
function setVideoTitle(devIdno,channel,stream,message)
{
    var ttxWindow = ttxPlayer.getCurrentChnWindow(devIdno,channel,stream);
	if(ttxWindow != null)
	{
		swfobject.getObjectById(flashObjId).setVideoTitle(ttxWindow.index, message);
	}
}

function doPlayAll() {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.playAll();
}

function doCloseAll() {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.stopAll();
}

function doClearAll() {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.clearAll();
}

/**
 * @method 启动监听
 * @param devIdno sim卡号
 * @param chn 通道号
 */

function startListen(devIdno, chn) {
	if (!isInitFinished) {
		return -1;
	}
	return ttxPlayer.startListen(devIdno, chn);
}

//停止监听
function stopListen() {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.stopListen();
}

/**
 * @method 启动对讲
 * @param devIdno simNo卡号，补零补足12位
 * @audioSampleRate 音频采样率 默认是44，单位khz
 * @encodeQuality 0-10, 默认是8 音频编码质量
 */
function startTalkback(devIdno,audioSampleRate,encodeQuality) {
	if (!isInitFinished) {
		return -1;
	}
	return ttxPlayer.startTalkback(devIdno,audioSampleRate,encodeQuality);
}

//停止对讲
function stopTalkback() {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.stopTalkback();
}

/**
 * 是否禁止系统右键  true 禁止
 */
function disableSysRight(id,disable,func) {
	if(disable) {
		if(typeof func != 'undefined' && func != null) {
			$(id).on('contextmenu',func);
		}else {
			$(id).on('contextmenu',function(){return false;});
		}
	}else {
		$(id).unbind('contextmenu');
	}
}

/**
 * 判断通道是否在播放
 */
function isPlaying(devIdno, channel, stream) {
	if (!isInitFinished) {
		return false;
	}
	return ttxPlayer.isPlaying(devIdno, channel, stream);
}

/**
 * 停止此通道的预览
 */
function stopChannelPreview(devIdno, channel, stream) {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.stopChannelPreview(devIdno, channel, stream);
};

//设置视频窗口标题
function setTvplayTitle(title) {
	if (!isInitFinished) {
		return ;
	}
	$('.tv_play_span').text(title);	
}

/**
 * 在报警情况下，当前批次的报警是否已经预览整个窗口
 */
function isAlarmPackAll(alarmPackNumber){
	if (!isInitFinished) {
		return true;
	}
	return ttxPlayer.isAlarmPackAll(alarmPackNumber);
};

/**
 * 在报警情况下，当报警结束时，让报警结束类型置空
 */
function setWindowEndArmType(devIdno, endArmType){
	if (!isInitFinished) {
		return;
	}
	ttxPlayer.setWindowEndArmType(devIdno, endArmType);
};

/**
 * 返回视频播放时间
 */
function getVideoWindowTime(){
	if (!isInitFinished) {
		return null;
	}
	return ttxPlayer.getVideoWindowTime();
}

/**
 * 根据链接地址播放回放视频
 * @param url
 */
function startVideoReplay(title, url) {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.startVideoReplay(title, url);
}

/**
 * 清除此回放视频窗口的预览
 */
function clearVideoReplay() {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.clearVideoReplay();
};

/**
 * 获取回放视频的播放时长
 */
function getVideoPlayTime() {
	if (!isInitFinished) {
		return ;
	}
	return ttxPlayer.getVideoPlayTime();
};

/**
 * 停止窗口所在通道视频
 */
function stopIndexWindowPreview(index) {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.stopIndexWindowPreview(index);
};

/**
 * 添加菜单
 * @param 窗口下标
 * @param menuId
 * @param menuName
 * @param part  是否分隔符 1,0
 */
function addVideoMenu(index, menuId, menuName, part) {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.addVideoMenu(index, menuId, menuName, part);
};

/**
 *  删除菜单
 *  @param 窗口下标
 *  @param menuId
 */
function delVideoMenu(index, menuId) {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.delVideoMenu(index, menuId);
};

/**
 *  清空窗口菜单
 *  @param 窗口下标
 */
function clearVideoMenu(index) {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.clearVideoMenu(index);
};

/*
 * 设置对讲播放的偏移
 */
function getTalkbackPlayTime() {
	if (!isInitFinished) {
		return ;
	}
	return ttxPlayer.getTalkbackPlayTime();
};

/*
 * 设置对讲播放的偏移（相对偏移）
 */
function setTalkbackPlayTime(offset) {
	if (!isInitFinished) {
		return ;
	}
	ttxPlayer.setTalkbackPlayTime(offset);
};
